import 'package:fate_blind_box/utils/common_widget.dart';
import 'package:flutter/material.dart';
import '../../../../theme/theme_color.dart';
import 'group_list_member_model.dart';

class GroupPromoteItemView extends StatelessWidget {
  MemberEaseGroup? itemModel;
  int count = 0;
  Function? choseAction;

  GroupPromoteItemView(
      {this.itemModel, this.count = 0, this.choseAction, Key? key})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    itemModel ??= MemberEaseGroup();
    String iconStr = itemModel!.isChose
        ? 'images/map/group_select_icon.png'
        : 'images/map/group_unselect_icon.png';
    return GestureDetector(
      onTap: () {
        if (choseAction != null) {
          choseAction!();
        }
      },
      child: Container(
        height: 70,
        padding: const EdgeInsets.symmetric(horizontal: 12),
        decoration: BoxDecoration(
          color: Colors.white,
          border: Border(
              top: BorderSide(color: ThemeColor.dividerColor, width: 1)),
        ),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.start,
          children: [
            Image.asset(
              iconStr,
              width: 16,
            ),
            const SizedBox(
              width: 15,
            ),
            AppWidget.commonEmptyImg(
                url: itemModel?.groupUrl ?? '', imgWidth: 50, imgHeight: 50),
            const SizedBox(
              width: 12,
            ),
            Expanded(
              child: Container(
                width: 200,
                padding: const EdgeInsets.symmetric(vertical: 12),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      itemModel?.groupName ?? '',
                      style: TextStyle(
                        color: ThemeColor.textColor,
                        fontSize: 15,
                        fontWeight: FontWeight.w600,
                        overflow: TextOverflow.ellipsis,
                      ),
                    ),
                    Row(
                      mainAxisAlignment: MainAxisAlignment.start,
                      children: [
                        Container(
                          padding: const EdgeInsets.only(
                              left: 8, right: 8, top: 1, bottom: 1),
                          alignment: Alignment.center,
                          decoration: ShapeDecoration(
                              shape: RoundedRectangleBorder(
                                borderRadius: BorderRadius.circular(36),
                              ),
                              color: const Color(0xffFE8A45)),
                          child: Row(
                            crossAxisAlignment: CrossAxisAlignment.center,
                            children: [
                              const Icon(
                                Icons.group_outlined,
                                color: Colors.white,
                                size: 12,
                              ),
                              Text(
                                count.toString(),
                                style: const TextStyle(
                                    color: Colors.white,
                                    fontSize: 11,
                                    fontWeight: FontWeight.normal),
                              ),
                            ],
                          ),
                        ),
                        Text(
                          itemModel?.description ?? '',
                          style: TextStyle(
                              color: ThemeColor.textColorSecond,
                              fontSize: 12,
                              fontWeight: FontWeight.w600),
                        ),
                      ],
                    ),
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
